package com.newshub.logging.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 日志系统配置属性
 */
@Data
@Component
@ConfigurationProperties(prefix = "logging")
public class LoggingProperties {
    
    /**
     * 日志系统总开关
     * 设置为false时，整个业务日志系统将被禁用
     */
    private boolean enabled = true;
    
    /**
     * 业务日志开关
     * 控制@BusinessLog注解是否生效
     */
    private boolean businessLogEnabled = true;
    
    /**
     * 性能日志开关
     * 控制@PerformanceLog注解是否生效
     */
    private boolean performanceLogEnabled = true;
    
    /**
     * 异常日志开关
     * 控制@ExceptionLog注解是否生效
     */
    private boolean exceptionLogEnabled = true;
    
    /**
     * 异步处理开关
     * 控制日志是否异步处理
     */
    private boolean asyncEnabled = true;
    
    /**
     * 日志级别配置
     */
    private Level level = new Level();
    
    /**
     * 存储配置
     */
    private Storage storage = new Storage();
    
    /**
     * 故障隔离配置
     */
    private FaultTolerance faultTolerance = new FaultTolerance();
    
    @Data
    public static class Level {
        /**
         * 业务日志级别
         */
        private String business = "INFO";
        
        /**
         * 性能日志级别
         */
        private String performance = "INFO";
        
        /**
         * 异常日志级别
         */
        private String exception = "ERROR";
    }
    
    @Data
    public static class Storage {
        /**
         * 文件存储开关
         */
        private boolean fileEnabled = true;
        
        /**
         * 数据库存储开关
         */
        private boolean databaseEnabled = false;
        
        /**
         * 控制台输出开关
         */
        private boolean consoleEnabled = true;
        
        /**
         * 文件存储详细配置
         */
        private File file = new File();
        
        @Data
        public static class File {
            /**
             * 日志文件路径
             */
            private String path = "logs";
            
            /**
             * 日志文件前缀
             */
            private String prefix = "news-hub";
            
            /**
             * 日志文件格式
             */
            private String format = "structured";
            
            /**
             * 最大文件大小
             */
            private String maxSize = "100MB";
            
            /**
             * 最大文件数量
             */
            private int maxCount = 10;
        }
    }
    
    @Data
    public static class FaultTolerance {
        /**
         * 故障隔离开关
         */
        private boolean enabled = true;
        
        /**
         * 熔断器失败率阈值
         */
        private int failureRateThreshold = 50;
        
        /**
         * 熔断器等待时间（秒）
         */
        private int waitDuration = 60;
    }
}



